package com.briup.cms.web.controller;

import com.briup.cms.bean.Privilege;
import com.briup.cms.bean.extend.PrivilegeExtend;
import com.briup.cms.service.IPrivilegeService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "用户权限模块接口")
@RestController
@RequestMapping("/Privilege")
public class PrivilegeController {

    @Autowired
    private IPrivilegeService iPrivilegeService;

    @ApiOperation("查询所有")
    @PostMapping("findAll")
    public Message findAll(){
        List<Privilege> list=iPrivilegeService.findAll();
        return MessageUtil.success(list);
    }

    @ApiOperation("按名称查找")
    @PostMapping("findInName")
    public Message findInId(String Name){
        List<Privilege> list=iPrivilegeService.findInNm(Name);
        return MessageUtil.success(list);
    }

    @ApiOperation("插入或更新")
    @GetMapping("insertOrUpdate")
    public Message insertOrUpdate(Privilege privilege){
        iPrivilegeService.insertOrUpdate(privilege);
        return MessageUtil.success("操作成功");
    }

    @ApiOperation("按id删除记录")
    @PostMapping("deleteInId")
    public Message deleteInId(Long id){
        iPrivilegeService.deleteInId(id);
        return MessageUtil.success("删除成功");
    }
}
